{% extends "index/open.html" -%}
{% block content -%}
<div id="forms">
    <input type="hidden" name="id" value="{{bo.id | default(value='')}}">
    <input type="hidden" name="userId" value="{{bo.userId | default(value=userId)}}">
    <div class="group-form">
        <label class="group-label required">奖惩时间</label>
        <div class="group-content">
            <input type="text" id="rewardDate" name="rewardDate" rule="txt:奖惩时间;required"
                value="{{bo.rewardDate | default(value='')}}" placeholder="请选择奖惩时间">
        </div>
    </div>
    <div class="group-form">
        <label class="group-label required">奖惩方式</label>
        <div class="group-content">
            <select name="types" rule="txt:奖惩方式;required" class="sel">
                <option value=""></option>
                {% for val in rewards -%}
                {% if val == bo.types | default(value='') -%}
                <option value="{{val}}" selected>{{val}}</option>
                {% else -%}
                <option value="{{val}}">{{val}}</option>
                {% endif -%}
                {% endfor -%}
            </select>
        </div>
    </div>
    <div class="group-form">
        <label class="group-label">奖惩金额</label>
        <div class="group-content">
            <input type="text" name="money" rule="txt:奖惩金额;double" value="{{bo.money | default(value='')}}"
                placeholder="请输入奖惩金额">
        </div>
    </div>
    <div class="group-form">
        <label class="group-label">请假天数</label>
        <div class="group-content">
            <input type="text" name="leaveDays" rule="txt:请假天数;int" value="{{bo.leaveDays | default(value='')}}">
        </div>
    </div>
    <div class="group-form">
        <label class="group-label">奖惩事件</label>
        <div class="group-content">
            <input type="text" name="reward" rule="txt:奖惩事件;length:50" value="{{bo.reward | default(value='')}}">
        </div>
    </div>
    <div class="group-form">
        <button type="button" onclick="save()" class="btn bg-royal" style="margin-left: 11rem;">提交</button>
        <button type="button" onclick="closePage()" class="btn bg-royal">关闭</button>
    </div>
</div>
<script type="text/javascript">
    ice(function () {
        iceui.use('date', function () {
            ice.date({id: 'rewardDate', format: 'y-m-d'});
        });
    });

    function save() {
        if (iceui.validateForm('forms')) {
            var data = iceui.readForm('forms');
            ice('button').attr('disabled', true);
            iceui.post('{{ctx}}/users/saveUsersReward.html', data,
                function (json) {
                    if (json.code == '20') {
                        iceui.pop('奖惩记录提交成功');
                        setTimeout(function(){
                            parent.location.href = '{{ctx}}/users/editUser.html?id=' + data.userId;
                        }, 2000);
                    }
                }
            );
        }
    }

    function closePage() {
        parent.closePop();
    }
</script>
{% endblock content -%}